/**
 *
 * @author 
 *
 */
class GuiZheView extends eui.Component{
    
    private guizhe:eui.Group;
    private im_close:eui.Image;
    private btn_close:eui.Rect;
    private btn_start:eui.Image;
    
    
	public constructor() {
    	  super();
        this.skinName = "resource/skins/GuiZheViewSkin.exml";
	}
	
    public createChildren() {
        super.createChildren();
        this.btn_close.addEventListener(egret.TouchEvent.TOUCH_TAP,this.closeView,this);
        this.btn_start.addEventListener(egret.TouchEvent.TOUCH_TAP,this.openView,this);
        this.btn_start.touchEnabled = false;
        this.btn_close.touchEnabled = false;
        this.init();
    }
    
    public init(){
        egret.Tween.get(this.guizhe).to({ y: 65 },500,egret.Ease.backOut).call(function() {
            this.btn_start.touchEnabled = true;
            this.btn_close.touchEnabled = true;
            document.getElementById("cross_tip").style.display = "inline";
        },this);
        egret.Tween.get(this,{ loop: true }).to({ t: Math.PI * 2 },800);
    }
    
    private _t: number = 0;
    get t(): number { return this._t; }
    set t(value: number) {
        this._t = value;
        this.btn_start.scaleX = Math.sin(value) * 0.05 + 1;
        this.btn_start.scaleY = Math.sin(value - Math.PI / 2) * 0.05 + 1;
        this.im_close.scaleX = Math.sin(value) * 0.05 + 1;
        this.im_close.scaleY = Math.sin(value - Math.PI / 2) * 0.05 + 1;
    }
    
    private closeView(ev:egret.TouchEvent){
        document.getElementById("cross_tip").style.display = "none";
        egret.Tween.get(this.guizhe).to({ y: -885 },500,egret.Ease.backOut).call(function(){
            this.parent.removeChild(this);
            ShouYeView.getInstance().initM();
            },this);
    }
    
    private openView(ev:egret.TouchEvent){
        this.addChild(GameScene.getInstance());
    }
}
